package com.wjb.controller;


import com.wjb.pojo.dto.OrderxDto;
import com.wjb.pojo.entity.Orderx;
import com.wjb.service.OrderService;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.util.UUID;

/**
 * @author : 王济彬
 * @date: 2025/5/24 - 05 - 24 - 15:54
 * @Description: com.wjb.controller
 * @version: 1.0
 */
@RestController
public class OrderCreateController {

    @Resource
    private OrderService orderService;

    @GetMapping("/create_order")
    public String createOrder(@RequestBody OrderxDto orderdto){
        System.out.println("创建成功");
        String uuid = UUID.randomUUID().toString();
        Orderx order = new Orderx();
        BeanUtils.copyProperties(orderdto,order);
        order.setOrderId(uuid);
        System.out.println(order);
        if(!orderService.insertOrder(order)){
            return "创建订单失败";
        }
        return "创建订单成功";
    }

}
